home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
vesa_tsr.zip
/
SAMPLES
/
VESABOX.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-01-11
|
16KB
|
574 lines
{-----------------------------------------------------------------------}
{VESABOX GL:01/05/90 }
{-----------------------------------------------------------------------}
{Program for viewing current screen characteristics in a VESA kind of }
{manner. }
{-----------------------------------------------------------------------}
{The following program is written to loosely conform to the VESA }
{Super VGA BIOS Extension document VS891001. The program is intended }
{as a demonstration and is not intended to be an example of a }
{high-performance implementations of the VESA standard. }
{If you find any omissions or errors, please report them to me on the }
{Everex Systems BBS at (415) 683-2984. }
{ Gary Lorensen }
{ Everex Systems, Inc. }
{ 48571 Milmont Dr. B3 }
{ Fremont, CA 94538 }
{-----------------------------------------------------------------------}
uses
dos;
{-----------------------------------------------------------------------}
const
ULCorner = #218; {Line drawing characters}
URCorner = #191;
LLCorner = #192;
LRCorner = #217;
VertBar = #179;
HorzBar = #196;
rSequAddr = $3C4;
{-----------------------------------------------------------------------}
type
s80 = string[80];
s8 = string[8];
CharString = array [$00..$03] of char;
ModeListType = array [$00..$00] of word;
PageFuncPtrType = pointer;
VgaInfoBlockType = record
VESASignature : CharString;
VESAVersion : word;
OEMStringPtr : ^CharString;
Capabilities : array [$00..$03] of byte;
VideoModePtr : ^ModeListType;
reserved : array [$00..$ED] of byte; {Pad to 256}
end;
ModeInfoBlockType = record
{mandatory information}
ModeAttributes : word;
WinAAttributes : byte;
WinBAttributes : byte;
WinGranularity : word;
WinSize : word;
WinASegment : word;
WinBSegment : word;
WinFuncPtr : PageFuncPtrType;
BytesPerScanLine : word;
{optional information}
XResolution : word;
YResolution : word;
XCharSize : byte;
YCharSize : byte;
NumberOfPlanes : byte;
BitsPerPixel : byte;
NumberOfBanks : byte;
MemoryModel : byte;
BankSize : byte;
reserved : array [$00..$E2] of byte; {Pad to 256}
end;
ScrCharType = record
ch : char;
attr : byte;
end;
ScrTextPtrType = ^ScrTextType;
ScrTextType = array [$0000..$0000] of ScrCharType;
ScrGrfxPtrType = ^ScrGrfxType;
ScrGrfxType = array [$0000..$0000] of byte;
{-----------------------------------------------------------------------}
{-----------------------------------------------------------------------}
var
reg : Registers;
VesaVgaInfo : VgaInfoBlockType;
VesaModeInfo : ModeInfoBlockType;
i : word;
VesaMode : word;
error : boolean;
textscr : ScrTextPtrType;
grfxscr : ScrGrfxPtrType;
pixofs : longint;
pixbank : byte;
prevbank : byte;
x,y : word;
{-----------------------------------------------------------------------}
{-----------------------------------------------------------------------}
function decval(ch : char) : byte;
begin
decval := 0;
if ((ch>='0') and (ch<='9')) then
decval := ord(ch)-ord('0');
if ((ch>='A') and (ch<='F')) then
decval := ord(ch)-ord('A')+$0A;
if ((ch>='a') and (ch<='f')) then
decval := ord(ch)-ord('a')+$0A;
end;
function hex2dec(s : s80) : word;
var
i : byte;
tmp : word;
place : word;
error : boolean;
begin
i := ord(s[0]);
error := false;
place := 1;
tmp := 0;
while (i>0) and not(error) do begin
error := not(((s[i]>='0')and(s[i]<='9'))
or ((s[i]>='a')and(s[i]<='f'))
or ((s[i]>='A')and(s[i]<='F')));
tmp := tmp+place*decval(s[i]);
i:=i-1;
place := place*$10;
end;
if (error) then
hex2dec := $FFFF
else
hex2dec := tmp;
end;
{-----------------------------------------------------------------------}
function hexval(x : byte) : char;
begin
hexval := '0';
if ((x>=0) and (x<=9)) then
hexval := chr(x+ord('0'));
if ((x>=10) and (x<=15)) then
hexval := chr(x-10+ord('A'));
end;
function dec2hex(x : word) : s8;
var
tmp : s8;
place : word;
begin
{ tmp := '0';}
tmp := ' ';
if (x>=$100) then
place := $1000
else
place := $10;
repeat
tmp := tmp+hexval(x div place);
x := x mod place;
place := place div $10;
until (place=$0000);
dec2hex := tmp+'h';
end;
function hex(x : word) : s8;
var
tmp : s8;
place : word;
begin
tmp := '0';
if (x>=$100) then
place := $1000
else
place := $10;
repeat
tmp := tmp+hexval(x div place);
x := x mod place;
place := place div $10;
until (place=$0000);
hex := tmp+'h';
end;
function addrhex(x : word) : s8;
var
tmp : s8;
place : word;
begin
tmp := '';
place := $1000;
repeat
tmp := tmp+hexval(x div place);
x := x mod place;
place := place div $10;
until (place=$0000);
addrhex := tmp;
end;
{-----------------------------------------------------------------------}
procedure SetVesaBank(win : byte;
bank : byte);
var
reg : Registers;
begin
reg.AX := $4F05;
reg.BH := $00;
reg.BL := win;
reg.DX := bank;
intr($10,reg);
end;
{-----------------------------------------------------------------------}
procedure GetVesaBank(win : byte;
var bank : byte);
var
reg : Registers;
begin
reg.AX := $4F05;
reg.BH := $01;
reg.BL := win;
intr($10,reg);
bank := reg.DX;
end;
{-----------------------------------------------------------------------}
{-----------------------------------------------------------------------}
begin
error := false;
writeln('VESA BIOS Extensions BOX program');
writeln('1990 Everex Systems, Inc.');
reg.AX := $4F00;
reg.ES := Seg(VesaVgaInfo);
reg.DI := Ofs(VesaVgaInfo);
intr($10,reg);
if (reg.AL<>$4F) then begin
writeln('ERROR: VESA Function 00h: Return Super VGA Information not supported.');
error := true;
end;
if (reg.AH<>$00) then begin
writeln('ERROR: VESA Function 00h: Return Super VGA Information failed.');
error := true;
end;
if not(error) then begin
reg.AX := $4F03;
intr($10,reg);
if (reg.al<>$4F) then
error := true;
if (reg.AH<>$00) then
error := true;
if not(error) then begin
VesaMode := reg.BX;
reg.AX := $4F01;
reg.CX := VesaMode;
reg.ES := Seg(VesaModeInfo);
reg.DI := Ofs(VesaModeInfo);
intr($10,reg);
if (reg.AL<>$4F) then
error := true;
if (reg.AH<>$00) then
error := true
else if ((error) or ((VesaModeInfo.ModeAttributes and $02)=$00)) then
error := true
else begin
write(VesaModeInfo.XResolution:4,'x',VesaModeInfo.YResolution:3);
if ((VesaModeInfo.ModeAttributes and $10)=$10) then
write('x',VesaModeInfo.NumberOfPlanes:1)
else
write(' ');
write(' ',VesaModeInfo.BitsPerPixel:1,'bpp');
write(' ',VesaModeInfo.XCharSize:2,'x',VesaModeInfo.YCharSize:2);
write(' ');
if ((VesaModeInfo.ModeAttributes and $08)=$08) then
write('Color ')
else
write('Mono ');
if (VesaModeInfo.BankSize>0) then
write(' ',VesaModeInfo.BankSize:2,'Kx',VesaModeInfo.NumberOfBanks:1);
if ((VesaModeInfo.WinAAttributes and $01)=$01) then begin
write('A:',addrhex(VesaModeInfo.WinASegment),' ');
if ((VesaModeInfo.WinAAttributes and $02)=$02) then
write('R')
else
write(' ');
if ((VesaModeInfo.WinAAttributes and $04)=$04) then